// Copyright 2020 Google Inc, Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializenumberformat
description: >
    Tests that the options numberingSystem are mapped to lower case.
author: Caio Lima
---*/

function Test() {
    let defaultLocale = new Intl.NumberFormat().resolvedOptions().locale;

    let supportedNumberingSystems = ["latn", "arab"].filter(nu =>
      new Intl.NumberFormat(defaultLocale + "-u-nu-" + nu)
        .resolvedOptions().numberingSystem === nu
    );

    if (supportedNumberingSystems.includes("latn")) {
      let numberFormat = new Intl.NumberFormat(defaultLocale + "-u-nu-lATn");
      assert.sameValue(numberFormat.resolvedOptions().numberingSystem, "latn", "Numbering system option should be in lower case");
    }

    if (supportedNumberingSystems.includes("arab")) {
      let numberFormat = new Intl.NumberFormat(defaultLocale + "-u-nu-Arab");
      assert.sameValue(numberFormat.resolvedOptions().numberingSystem, "arab", "Numbering system option should be in lower case");
    }
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
